using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class ConfigurationSettingController
    {
		private ConfigurationSettingInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				ConfigurationSettingInfo obj = new ConfigurationSettingInfo();
				obj.ConfigurationId = dr.Field<Guid>("ConfigurationId"); 
				obj.SettingId = dr.Field<Guid>("SettingId"); 
				obj.Active = (dr["Active"] != DBNull.Value) ? dr.Field<Boolean>("Active") : false; 
				obj.PermissionFlag = (dr["PermissionFlag"] != DBNull.Value) ? dr.Field<String>("PermissionFlag") : string.Empty; 
				obj.Value = (dr["Value"] != DBNull.Value) ? dr.Field<String>("Value") : string.Empty; 
				obj.Pattern = (dr["Pattern"] != DBNull.Value) ? dr.Field<String>("Pattern") : string.Empty; 
				obj.Replacement = (dr["Replacement"] != DBNull.Value) ? dr.Field<String>("Replacement") : string.Empty; 
				return obj;
            }
            return null;
        }

        private List<ConfigurationSettingInfo> ListFromDataTable(DataTable dt)
        {
            List<ConfigurationSettingInfo> lst = new List<ConfigurationSettingInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
